#include <bits/stdc++.h>
#define LL long long
using namespace std;

LL read(){
    LL x = 0, f = 1; char ch = getchar();
    while(!isdigit(ch)){if(ch == '-')f = -1; ch = getchar();}
    while(isdigit(ch)){x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar();}
    return x * f;
}

const int maxn = 2e3 + 5;

int n; LL a[maxn];
int f[maxn], lst[2];

LL cal(){
    lst[0] = lst[1] = 1; 
    LL res = 0;
    for(int i = 2; i <= n; i++){
        if(lst[f[i]] && a[lst[f[i]]] == a[i]) res += a[i];
        lst[f[i]] = i;
    }
    return res;
}

void solve(){
    n = read();
    for(int i = 1; i <= n; i++) a[i] = read();
    LL ans = 0;
    for(int i = 0; i < (1ll << n); i++){
        for(int j = 1; j <= n; j++) f[j] = (i >> (j - 1)) & 1;
        ans = max(ans, cal());
    } cout << ans << "\n";
}

int main(){
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    int _ = read();
    while(_--) solve();
    return 0;
}